<?php 

	require "config.php";
	
	session_start();
	
	if(isset($_POST['edit-btn'])){
		
		header("Location: editvideo.php?videoid=$_GET[videoid]");
		
	}
	
	if(isset($_POST['del-btn'])){
		
		header("Location: delvideo.php?videoid=$_GET[videoid]");
		
	}

?>
<!DOCTYPE html>
<html lang="hu">

	<head>
		
		<!-- TITLE -->
		<title>Videóid</title>
		
		<!-- CSS -->
		<link rel="stylesheet" href="css/style.css">
		
	</head>
	<body>
	
		<!-- NAV -->
		<?php require "nav.php"; ?>
		
		<!-- CONTENT -->
		<div class="video-list">
			
			<?php 
			
				$lekerdezes = "SELECT * FROM videos WHERE userid=$_SESSION[id]";
				$talalt_videok = $conn->query($lekerdezes);
				while($video=$talalt_videok->fetch_assoc()){
					
					$lekerdezes = "SELECT * FROM comments WHERE videoid=$video[id]";
					$talalt_kommentek = $conn->query($lekerdezes);
					$kommentek = mysqli_num_rows($talalt_kommentek);
			
			?>
			
				<form class="video" method="post" action="videos.php?videoid=<?= $video['id']; ?>">
					<label><?= $video['name']; ?></label>
					<input type="submit" name="del-btn" value="Törlés" style="margin-left: 10px; background: red ; color: white;">
					<input type="submit" name="edit-btn" value="Szerkesztés">
					<label class="video-comment"><?= $kommentek; ?> komment</label>
					<label class="video-views"><?= $video['viewcount']; ?> megtekintés</label>
				</form>
			
			<?php } ?>
			
		</div>
		
	
	</body>
	
	<?php require "footer.php"; ?>
	
</html>